#include "StdAfx.h"
#include "ImageProcStep.h"
#include "ProcParamDefInt.h"
#include "ProcParamDefDouble.h"
#include "ProcParamInt.h"
#include "ProcParamDouble.h"
#include "ImageProcFn.h"
#include "DummyAnalysis.h"

const char * const DummyAnalysis::FunctionNameDummyAnalysis = "CalcScore";

DummyAnalysis::DummyAnalysis(void)
{
	_fnApi.SetFunctionName(DummyAnalysis::FunctionNameDummyAnalysis);
	_fnApi.SetFunctionDescription("this is a dummy function with one i/p param and two o/p param");
									//inputs
	_fnApi.AddParamDef(new ProcParamDefInt(0, "brightness", "sets brightness of image in range 0 to 100", ProcParamDef::input, 0, 100 ));
									//outputs
	_fnApi.AddParamDef(new ProcParamDefInt(0, ProcParam::attribOutputParamNameResult, "0 is success; 1 is exception", ProcParamDef::output, 0, 1));
	_fnApi.AddParamDef(new ProcParamDefDouble(1, ProcParam::attribOutputParamNameScore, "process simply copies input value to score value and sets result = 0", ProcParamDef::output, 0.0, 100.0));

	_fnApi.Validate();
}


DummyAnalysis::~DummyAnalysis(void)
{
}


bool DummyAnalysis::Process(ImageProcStep *step, bool DebugMode)
{
	bool rc = false;
	if ((step != '\0') && (step->IsValid()))
	{
		ProcParamInt *input = dynamic_cast<ProcParamInt *>(step->GetInputs()->GetParam(0));
		ProcParamInt *result = dynamic_cast<ProcParamInt *>(step->GetOutputs()->GetParam(0));
		ProcParamDouble *score = dynamic_cast<ProcParamDouble *>(step->GetOutputs()->GetParam(1));

		if ((input != '\0') && (result != '\0') && (score != '\0'))
		{
			score->SetValue((double)input->GetValue());
			result->SetValue(0);
			rc = true;
		}
	}
	return rc;
}

